package com.wjjun.databinding;

import android.databinding.BindingAdapter;
import android.support.design.widget.TabLayout;

import com.wjjun.presenter.TabViewPagerPresenter;
import com.wjjun.viewmodel.TabViewPagerViewModel;

/**
 * tabLayout
 * Created by 67535 on 2018/4/27.
 */

public class TabLayoutAdapter {

    @BindingAdapter(value = "onTabChange")
    public static void bindOnTabChange(TabLayout tabLayout, TabLayout.OnTabSelectedListener listener) {
        if (listener != null) {
            tabLayout.addOnTabSelectedListener(listener);
        }
    }

    @BindingAdapter(value = {"bindPresenter", "bindTabs"})
    public static void bindTabs(TabLayout tabLayout, TabViewPagerPresenter bindPresenter, TabViewPagerViewModel bindTabs) {
        if (bindPresenter == null || bindTabs == null) {
            return;
        }
        bindPresenter.bindTabLayout(tabLayout);
        bindPresenter.bindTabViewModel(bindTabs);
    }

}
